package emulator.hardware.nmos6502.commands;

import emulator.EmulatorException;
import emulator.hardware.HwByte;
import emulator.hardware.nmos6502.Command;
import emulator.hardware.nmos6502.CommandSet;
import emulator.hardware.nmos6502.Cpu6502;
import emulator.hardware.nmos6502.Flags6502;
import emulator.hardware.nmos6502.Operand;
import emulator.hardware.nmos6502.operands.NoOperand;

/** DEY (DEcrement Y) */
public class DEY implements Command {

	@Override
	public void execute(Cpu6502 cpu, Operand operand) throws EmulatorException {
		HwByte y = cpu.getY();
		y.inc(-1);
		cpu.setY(y);
		Flags6502 flags = cpu.getFlags();
		flags.setNZFromValue(y);
		cpu.setFlags(flags);
	}

	@Override
	public String getName() {
		return "DEY";
	}

	@Override
	public void register(CommandSet cset) {
		cset.defineCommand(0x88, this, new NoOperand());
	}

}
